package com.htrq.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.htrq.dao.ICKczDao;
import com.htrq.entity.ICKcz;
import com.htrq.entity.Page;
import com.htrq.entity.TotalMoney;
@Service
@Transactional(value="txManager2")
public class ICardczService {
	
	@Resource
	private ICKczDao czDao;
	
	public List<ICKcz> getAllkcz(ICKcz kcz, Page page) throws ParseException {
		//TODO Auto-generated method stub
		List<Object[]> list=czDao.getAllkcz(kcz,page);
		List<ICKcz> czs=new ArrayList<ICKcz>();
		for(Object [] obj:list){
			ICKcz cz=new ICKcz();
			cz.setAutoId(obj[0].toString());
			cz.setNodeName(obj[1].toString());
			cz.setCardNumber(obj[2].toString());
			cz.setCardType(obj[3].toString());
			cz.setCzDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(obj[4].toString()));
			cz.setUserName(obj[5].toString());
			cz.setCzMoney(Double.parseDouble(obj[6].toString()));
			cz.setYhMoney(Double.parseDouble(obj[7].toString()));
			cz.setLastBalance(Double.parseDouble(obj[8].toString()));
			cz.setCurrBalance(Double.parseDouble(obj[9].toString()));
			cz.setNote(obj[10].toString());
			cz.setJnfs(obj[11].toString());
			cz.setCname(obj[12].toString());
			cz.setVehicleId(obj[13].toString());
			cz.setIDcard(obj[14].toString());
			cz.setTel(obj[15].toString());
			cz.setCompany(obj[16].toString());
			czs.add(cz);
		}
		return czs;
	}

	public Long getTotal(ICKcz kcz) {
		//TODO Auto-generated method stub
		return (long) czDao.getTotal(kcz);
	}

	public TotalMoney getMoneyandNum(ICKcz kcz) {
		//TODO Auto-generated method stub
		//String str=czDao.getMoneyandNum(kcz);
		List<Object> list=czDao.getMoneyandNum(kcz);
		TotalMoney tot=new TotalMoney();
		//list.get(0)[0].toString();
		tot.setMoney(list.get(0).toString());
		return tot;
	}

	public List<Object[]> exportbyForm(ICKcz kcz) {
		//TODO Auto-generated method stub
		return czDao.exportbyForm(kcz);
	}
}
